package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.pojo.Administrators;
import com.itheima.pojo.User;
import com.itheima.service.AdministratorsService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/administrators")
public class Administratorss {
    @Reference
    private AdministratorsService administratorsService;
    @RequestMapping("/findByName")
    public Administrators findByName(@RequestBody Administrators administrators){
        String name = administrators.getName();
        Administrators administrators2 = administratorsService.findByName(name);
        return administrators2;
    }
    @RequestMapping("/editPassword")
    public Result editPassword(@RequestBody Administrators administrators){

        try{
            administratorsService.editPassword(administrators);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,"修改密码失败");
        }
        return new Result(true,"修改密码成功");
    }
}
